<jsp:include page="../../header.jsp">
			<jsp:param value="item5" name="item"/>
</jsp:include> 
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
/*if((request.getAttribute("routesetsuccess")!=null)&&(request.getAttribute("routesetsuccess").equals("1"))){
	out.println("<script>alert('设定成功');</script>");
}*/
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<section class="content">
	<section class="widget"  id="department" >
		<header>
			<span class="icon">&#128196;</span>
			<hgroup>
				<h1>出差记录表</h1>
				<h2>详情列表</h2>
			</hgroup>
		</header>
		<div class="content">
	  		<div id="back">
	  			<a href="<s:url action="route!routeSetPrepareSetting.action" />" ><input type="button" class="button white" value="制定路线"></a>
	  		</div>
		  	<div id="btlist">
			    <table name="btlist" id="myTable">
			    	<tr>
			    		<th>出差单号</th> <th>开始时间</th> <th>结束时间</th> <th>总金额</th> <th>审核状态</th><th>操作</th>
			    	</tr>
			    	<s:iterator value="btlist" id="row" status="status">
			    		<tr>
			    			<td id="btlistitem"><s:property value="#row.travelOrder" /></td>
			    			<td><s:property value="#row.startTime" /></td>
			    			<td><s:property value="#row.endTime" /></td>
			    			<td><s:property value="#row.amount" /></td>
			    			<td><s:property value="#row.verifierStatus" /></td>
			    			<td><a href="<s:url action="route!routeSetPrepareSetting.action?travelOrder=%{#row.travelOrder}" />" ><input type="button" class="button white"  value="修改" /></a></td>
			    		</tr>
			    	</s:iterator>
			    </table>
		    </div>
   			<div id="popup" class="hide">
	    		
	    	</div>
		</div>
	</section>    
	<script type="text/javascript">
	
		var msg = "${requestScope.routesetsuccess}";
			if(msg=="1"){
				alert("设定成功");
			}
	
		$("td#btlistitem").css("cursor","pointer").click(function(){	//点击表单中的出差单号	
			var id = this.innerHTML;
					layer.open({
					        type: 1,
					        skin:'layui-layer-lan',
					        area: ['630px', '540px'],
					        shadeClose: true, //点击遮罩关闭
					        content:$('#popup')
					    });	
				$.ajax({
					url: "route!showSingleRoute.action",
					type: "get",
					data: {"travelOrder":id},
					dataType: "json",
					contentType: "application/json",
					success: function(jsonResult){
						showroute(jsonResult);
					},
					fail: function(){
						alert("fail");
					}
				});
		});
		
		function showroute(jsonResult){	//thead--theadtr
			var data = eval("("+jsonResult+")");
			var tbody = document.getElementById("popup");
			var result = "";
			result += "<strong>金额计算规则:</strong>";
			result += "</br>";
			result += "<strong>本次金额=(交通标准单位金额*公里数)+(住宿标准单位金额*天数)+(餐饮单位费用*天数)+其他费用</strong>";
			result += "<br/>";
			result += "你的标准费用为&emsp;交通：<s:property value='userts.traffic.price' />元；";
			result += "住宿：<s:property value='userts.hotel.price' />元；";
			result += "餐饮：<s:property value='userts.mealsCost' />元；";
			result += "其他费用：<s:property value='userts.elseCost' />元。";
			
			result += "<table id='myTable'><tr>";
			result += "<th>开始地点</th>";
			result += "<th>结束地点</th>";
			result += "<th>天数</th>";
			result += "<th>路程</th>";
			result += "<th>本次金额</th>";
			result += "</tr>";
			for(var i=0;i<data.length;i++){
				result += "<tr>";
				result += "<td>"+data[i].startPlace+"</td>";
				result += "<td>"+data[i].endPlace+"</td>";
				result += "<td>"+data[i].time+"</td>";
				result += "<td>"+data[i].distance+"</td>";
				result += "<td>"+data[i].sum+"</td>";
				result += "</tr>";
			}
			result += "</table>";
			tbody.innerHTML = result;
			
			if((tbody.style.display=='none')){
				tbody.style.display='inline';
			}
		}
		
		/*关闭添加信息窗口*/
	    function closeWin(){
			var popup = document.getElementById("popup");
			popup.className = "hide";
			var mybg = document.getElementById("mybg");
			mybg.parentNode.removeChild(mybg);
	    }
	</script>
<%@ include file="../../footer.jsp" %>
